package com.kwedding.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kwedding.dto.web.RequestWebAddBrandSchedule;
import com.kwedding.dto.web.RequestWebGetBrandSimple;
import com.kwedding.dto.web.RequestWebGetScheduleList;
import com.kwedding.dto.web.RequestWebUpdateSchedule;
import com.kwedding.dto.web.ResponseWebBrandSimple;
import com.kwedding.dto.web.ResponseWebSceduleList;
import com.kwedding.service.web.WebScheduleService;
import com.kwedding.util.BackJson;
import com.kwedding.util.JsonBack;
import com.kwedding.util.JsonBackBase;
import com.kwedding.util.LoggerParent;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@RequestMapping("/rest/web/schedule")
@Api(tags = "Web-档期")
public class WebScheduleController extends LoggerParent {

	@Autowired
	private WebScheduleService webScheduleService;

	@ApiOperation(" 获取地区可用品牌")
	@ResponseBody
	@RequestMapping(value = "getBrandSimple", method = { RequestMethod.POST })
	private JsonBackBase<List<ResponseWebBrandSimple>> getBrandSimple(
			@RequestBody RequestWebGetBrandSimple getBrandSimple) {
		return BackJson.successObj(webScheduleService.getBrandSimple(getBrandSimple));
	}

	@ApiOperation("添加品牌档期")
	@ResponseBody
	@RequestMapping(value = "insertBrandSchedule", method = { RequestMethod.POST })
	private JsonBack insertBrandSchedule(@RequestBody RequestWebAddBrandSchedule addBrandSchedule) {
		webScheduleService.insertBrandSchedule(addBrandSchedule);
		return BackJson.success();
	}

	@ApiOperation("根据品牌获取该品牌现年所有的档期")
	@ResponseBody
	@RequestMapping(value = "getScheduleList", method = { RequestMethod.POST })
	private JsonBackBase<List<ResponseWebSceduleList>> getScheduleList(
			@RequestBody RequestWebGetScheduleList getScheduleList) {
		return BackJson.successObj(webScheduleService.getScheduleList(getScheduleList));
	}

	@ApiOperation("修改品牌档期")
	@ResponseBody
	@RequestMapping(value = "updateSchedule", method = { RequestMethod.POST })
	private JsonBack updateSchedule(@RequestBody RequestWebUpdateSchedule updateSchedule) {
		webScheduleService.updateSchedule(updateSchedule);
		return BackJson.success();
	}

}
